package com.west_traveler.viewpager_adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.west_traveler.subsrcibe_page_fragment.SubHistoryFragment;
import com.west_traveler.subsrcibe_page_fragment.SubRecommendFragment;
import com.west_traveler.subsrcibe_page_fragment.SubSubscribeFragment;

/**
 * Description: xxx
 * Date:2016年12月05日15:36
 *
 * @author: 刘悦.
 */

public class SubscribePageViewPagerAdapter extends FragmentStatePagerAdapter {

    private String[] tabNames;

    public SubscribePageViewPagerAdapter(FragmentManager fm, String[] tabNames) {
        super(fm);
        this.tabNames = tabNames;
    }

    @Override
    public Fragment getItem(int position) {

        switch (position) {
            case 0:
                return SubRecommendFragment.getInstance();
            case 1:
                return SubSubscribeFragment.getInstance();
            case 2:
                return SubHistoryFragment.getInstance();
            default:
                return SubRecommendFragment.getInstance();
        }

    }

    @Override
    public int getCount() {
        return tabNames.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabNames[position];
    }
}
